package com.diankangwo.factory.controller;

import com.diankangwo.common.annotation.SysLog;
import com.diankangwo.common.utils.R;
import com.diankangwo.common.validator.ValidatorUtils;
import com.diankangwo.common.validator.group.AddGroup;
import com.diankangwo.common.validator.group.UpdateGroup;
import com.diankangwo.factory.entity.TdSms;
import com.diankangwo.factory.service.TdSmsService;
import com.diankangwo.sys.controller.AbstractController;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wuye on 2017/9/11.
 */
@RestController
@RequestMapping("/fac/sms")
public class TdSmsController extends AbstractController {

    @Autowired
    private TdSmsService tdSmsService;

    /**
     * 保存一条第三方短信
     */
    @ApiOperation(value = "保存一条第三方短信",notes = "")
    @ApiImplicitParam(name = "tdSms",value = "第三方短信",required = true,dataType = "TdSms")
    @SysLog("保存商品")
    @RequestMapping("/save")
    @RequiresPermissions("fac:sms:save")
    public R save(@RequestBody TdSms tdSms){
        ValidatorUtils.validateEntity(tdSms, AddGroup.class);
        tdSmsService.save(tdSms);
        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改一条第三方短信",notes = "")
    @ApiImplicitParam(name = "tdSms",value = "新的第三方短信",required = true,dataType = "TdSms")
    @SysLog("保存商品")
    @RequestMapping("/update")
    @RequiresPermissions("fac:sms:update")
    public R update(@RequestBody TdSms tdSms){
        ValidatorUtils.validateEntity(tdSms, UpdateGroup.class);
        tdSmsService.update(tdSms);
        return R.ok();
    }
}
